﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
using System.Web.Script.Serialization;

namespace HinokyWeb.Controllers
{
    public class JsonParserController : Controller
    {
        //
        // GET: /JsonParser/

        public ActionResult Index()
        {
            var jsonFilePath = Path.Combine(@"D:\SKchemConfigFile", "menuKrData.js");

            if (System.IO.File.Exists(jsonFilePath))
            {
                var jsonString = string.Empty;
                using (TextReader jsonReader = new StreamReader(jsonFilePath, Encoding.Default, true))
                    jsonString = jsonReader.ReadToEnd();

                var jss = new JavaScriptSerializer();
                jss.RegisterConverters (new JavaScriptConverter[] { new DynamicJsonConverter() });

                dynamic menuData = jss.Deserialize(jsonString, typeof(object));

                if (menuData.menuKrData != null)
                {
                    if (menuData.mnu01 != null)
                    {
                        
                    }
                }
            }
            return View();
        }

    }
}
